import React from 'react'
import { Route, IndexRoute } from 'react-router'
import Menu from 'ROUTE/menu/menu'
import No from 'ROUTE/noContent'
import ErrorPage from 'VIEW/errorPage/errorPage'

const Login = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/login').default)
  }, 'login')
}
const Forget = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/password/forget').default)
  }, 'forget')
}
const Index = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW').default)
  }, 'index')
}
const Antd = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/antd').default)
  }, 'antd')
}
const Editor = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/editor/editor').default)
  }, 'editor')
}
const UEditor = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/editor/ueditor').default)
  }, 'ueditor')
}
const TestInput = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/editor/testInput').default)
  }, 'testInput')
}
const Modal = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/myComponents/modal').default)
  }, 'modal')
}
const Drawer = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/myComponents/draw').default)
  }, 'drawer')
}
const ChangePwd = (location, cb) => {
  require.ensure([], (require) => {
    cb(null, require('VIEW/password/changepwd').default)
  }, 'changepwd')
}

export default (
  <Route path="/">
    <Route path="login" getComponent={ Login }/>
    <Route path="forget" getComponent={ Forget } />
    <Route component={ Menu }>
      <IndexRoute getComponent={ Index }/>
      <Route path="third" component={ No }>
        <Route path="antd" getComponent={ Antd }/>
        <Route path="wangeditor" getComponent={ Editor }/>
        <Route path="ueditor" getComponent={ UEditor }/>
        <Route path="testInput" getComponent={ TestInput }/>
      </Route>
      <Route path="my" component={ No }>
        <Route path="modal" getComponent={ Modal }/>
        <Route path="drawer" getComponent={ Drawer }/>
      </Route>
      <Route path="changepwd" getComponent={ ChangePwd } />
    </Route>
    <Route path="*" component={ ErrorPage } />
  </Route>
)

